package com.gml.design.other.singleton;

/**
 * @ClassName : Singleton02
 * @Description : 单例模式第二种，类似第一种
 * @Author : gml
 * @Date: 2021-04-01 14:02
 */
public class Singleton02 {

    private final static Singleton02 INSTANCE;

    private Singleton02(){
    }

    static {
        INSTANCE = new Singleton02();
    }

    public static Singleton02 getInstance(){
        return INSTANCE;
    }

    public void say(){
        System.out.println("hello");
    }

    public static void main(String[] args) {
        Singleton02.getInstance().say();
    }
}
